package com.prs.crm.service.flow;

import java.util.Collection;
import java.util.List;

import com.prs.crm.domain.flow.WorkFlow;
import com.prs.crm.domain.flow.WorkFlowHandler;
import com.prs.crm.domain.flow.WorkFlowInstance;
import com.prs.crm.domain.flow.WorkFlowInstanceNode;
import com.prs.crm.domain.flow.WorkFlowType;
import com.prs.crm.domain.sys.Form;
import com.prs.crm.service.BaseService;
import com.prs.crm.vo.flow.FlowExecutor;
import com.prs.crm.vo.flow.FlowView;

public interface WorkFlowInstanceService extends BaseService<WorkFlowInstance>  {

	//void save(WorkFlowInstance instance,Integer[] responsibleTypes);
	void save(WorkFlowInstance instance,List<WorkFlowHandler> handlers);

	/**
	 * 查询强制执行的流程
	 * @param form
	 * @return
	 */
	WorkFlowInstance findEnforeInstance(Form form );
	
	/**
	 * 查询表单关联流程 
	 * @param form
	 * @return
	 */
	Collection<WorkFlowInstance> findFormInstance(Form form,WorkFlowType type);
	
	void executeEnable(WorkFlowInstance instance);
	
	void executeDisable(WorkFlowInstance instance);
	
	int countFlowInstance(WorkFlow workflow);
	
	WorkFlowInstance getFormFlowInstance(Form form,WorkFlow flow);
	
	/**
	 * 根据一个实例渲染显示需要的VO
	 * @param instance
	 * @return
	 */
	FlowView convert(WorkFlowInstance instance);
	
	FlowExecutor convertHandler(WorkFlowInstanceNode node);
	WorkFlowInstance findByFormName(String name);
	List<WorkFlowInstance> getAllWorkFlowInstance();
}
